#include <stdio.h>

int main()
{
    int n, max, min, num;
    scanf("%d", &n);
    scanf("%d", &num);
    max = num;
    min = num;
    for (int i = 1; i < n; i++)
    {
        scanf("%d", &num);
        if (num > max)
        {
            max = num;
        }
        if (num < min)
        {
            min = num;
        }
    }
    printf("%d", max - min);
    return 0;
}

